<template>
	<view class="container">
		<block v-if="listData.length > 0">
			<block v-for="(item, index) in listData" :key="index">
				<member :item="item" :type="'birthday'"></member>
			</block>
		</block>
		<block v-else>
			<view class="all_empty">
				<u-empty mode="data" text="生日列表为空"></u-empty>
			</view>
		</block>
		<u-loadmore v-if="listData.length > searchForm.limit" :status="status" :loading-text="loadingText" :loadmore-text="loadmoreText" :nomore-text="nomoreText" />
	</view>
</template>

<script>
export default {
	data() {
		return {
			searchForm: {
				limit: 10,
				page: 1
			},
			listData: [],
			status: 'loadmore',
			loadingText: '努力加载中',
			loadmoreText: '轻轻上拉',
			nomoreText: '实在没有了'
		};
	},
	onLoad() {
		this.$initConfig().then((_) => {
			this.getInfo();
		});
	},
	onReachBottom() {
		if (this.status != 'nomore') {
			this.searchForm.page++;
			this.getInfo(true);
		}
	},
	methods: {
		getInfo(is_add = false) {
			let _this = this;
			this.status = 'loading';
			_this
				.$http('crop/getUserBirthday', {
					...this.searchForm
				})
				.then((res) => {
					if (res.code) {
						if (is_add) {
							_this.listData = _this.listData.concat(res.data.data);
						} else {
							_this.listData = res.data.data;
						}
						if (_this.listData.length >= res.data.total) {
							this.status = 'nomore';
						} else {
							this.status = 'loadmore';
						}
					}
				});
		}
	}
};
</script>

<style lang="scss" scoped></style>
